#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
int cnt[N];
int n;
int main()
{
	int t;
	scanf("%d", &t);
	while (t--) {
		scanf("%d", &n);
		memset(cnt, 0, sizeof(cnt));
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			int x;
			scanf_s("%d", &x);
			if (x <= n) {
				cnt[x]++;
			}
		}
		for (int i = 1; i <= n; i++) {
			if (!cnt[i]) continue;
			for (int j = i * 2; j <= n; j += i) {
				cnt[j] += cnt[i];
			}
		}
		for (int i = 1; i <= n; i++) {
			ans = max(ans, cnt[i]);
		}
		cout << ans << endl;
	}
	return 0;
}